#include "Archer.h"
#include "AIManager.h"
#include "ArcherAI.h"

Archer::Archer(bool IsPlayer)
{
	//SetExp(99);
	SetHP(30);
	SetMaxHP(30);
	SetMP(0);
	SetMaxMP(0);
	SetAtk(8);
	SetDef(6);
	SetSpd(5);
	SetAgi(10);
	SetSta(5);
	SetMov(3);
	SetRng(2);
	SetWpn(0);
	SetArm(0);
	SetWpnName(nullptr);
	SetArmName(nullptr);
	SetPlayer(IsPlayer);
	SetMoved(false);
	SetActed(false);
	type = ARCHER;
	hpGain = 3;
	mpGain = 0;
	atkGain = 2;
	defGain = 2;
	spdGain = 2;
	agiGain = 2;
	stmGain = 2;
	AniMan = AnimationManager::GetInstance();
	ChangeState(ARCH_IDLE + GetFacing());
	this->currentTile = NULL;

	if(!this->IsPlayer())
	{
		this->currAI = new ArcherAI();
		currAI->SetCharIndex(AIManager::GetInstance()->GetAIChars()->size());
		AIManager::GetInstance()->GetAIChars()->push_back(this);
	}
	else
	{
		this->currAI = nullptr;
	}

}


Archer::~Archer(void)
{
	if(this->currAI != nullptr)
		delete this->currAI;
}

void Archer::Update(float elapsedTime)
{
	AniMan->Update(this, elapsedTime);
	if(GetHP() <= 0 && !this->IsDead())
	{
		dying = true;
		SetDead(true);
		SetHP(0);
	}

	if(dying)
	{
		ChangeState(ARCH_DEATH);
		dying = false;
	}
}

void Archer::Render()
{
	AniMan->Render(this);
}
